<%@page import="twitter4j.TwitterException"%>
<%@page import="twitter4j.auth.RequestToken"%>
<%@page import="twitter4j.TwitterFactory"%>
<%@page import="twitter4j.auth.AccessToken"%>
<%@page import="twitter4j.Twitter"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String consumerKey = getServletContext().getInitParameter(
			"ConsumerKey");
	String consumerSecret = getServletContext().getInitParameter(
			"ConsumerSecret");
	Twitter twitter = new TwitterFactory().getInstance();
	twitter.setOAuthConsumer(consumerKey, consumerSecret);

	RequestToken reqTok = null;
	try {
		reqTok = twitter.getOAuthRequestToken();
	} catch (TwitterException e) {
		e.printStackTrace();
	}
	if (reqTok != null) {
		String reqToken = reqTok.getToken();
		String reqTokenSecret = reqTok.getTokenSecret();
		session.setAttribute("requestToken", reqTok);
		session.setAttribute("twitter", twitter);
	}
	response.sendRedirect(reqTok.getAuthorizationURL());
%>
